package com.xposed.aliproxy.pollinglooper;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

import com.xposed.aliproxy.pollinglooper.poll.Constants;
import com.xposed.aliproxy.pollinglooper.poll.PollListener;
import com.xposed.aliproxy.pollinglooper.poll.PollingUtil;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.start).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PollingUtil.startPollingService("action_001", new PollListener() {
                    @Override
                    public void onHandlePoll() {
                        Log.d("ksdfjksda", "action_001");
                    }
                }, Constants.DEFAULT_MIN_POLLING_INTERVAL);
            }
        });


        findViewById(R.id.start1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PollingUtil.startPollingService("action_002", new PollListener() {
                    @Override
                    public void onHandlePoll() {
                        Log.d("ksdfjksda", "action_002");
                    }
                }, 5000);
            }
        });


        findViewById(R.id.stop).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PollingUtil.stopPollingServices("action_001");
            }
        });
    }
}
